package com.example.demo.dao;

import com.example.demo.dataobject.GaoyuanRecord1;

import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Component;

@Component
@Mapper
public interface GaoyuanRecord1Mapper {

    @Delete({
            "delete from gaoyuan_record1",
            "where name = #{name,jdbcType=VARCHAR}"
    })
    int deleteByAll(String name);

    @Insert({
            "insert into gaoyuan_record1 (id, name, ",
            "sex, age, birthday, ",
            "phone, email, address, ",
            "profession)",
            "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
            "#{sex,jdbcType=VARCHAR}, #{age,jdbcType=VARCHAR}, #{birthday,jdbcType=VARCHAR}, ",
            "#{phone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, ",
            "#{profession,jdbcType=VARCHAR})"
    })
    int insert(GaoyuanRecord1 record);


    @Select({
            "select",
            "name",
            "from gaoyuan_record1",
            "where name=#{name}"
    })
    @ResultMap("user")
    GaoyuanRecord1 selectByName(@Param("name") String name);


    @Select({
            "select",
            "id, name, sex, age, birthday, phone, email, address, profession",
            "from gaoyuan_record1",
            "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
//            @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "sex", property = "sex", jdbcType = JdbcType.VARCHAR),
            @Result(column = "age", property = "age", jdbcType = JdbcType.VARCHAR),
            @Result(column = "birthday", property = "birthday", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "email", property = "email", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "profession", property = "profession", jdbcType = JdbcType.VARCHAR)
    })
    List<GaoyuanRecord1> selectName(String name);

    @Select({
            "select",
            "id, name, sex, age, birthday, phone, email, address, profession",
            "from gaoyuan_record1"
    })
    @Results(id = "user", value = {
            @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "sex", property = "sex", jdbcType = JdbcType.VARCHAR),
            @Result(column = "age", property = "age", jdbcType = JdbcType.VARCHAR),
            @Result(column = "birthday", property = "birthday", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "email", property = "email", jdbcType = JdbcType.VARCHAR),
            @Result(column = "address", property = "address", jdbcType = JdbcType.VARCHAR),
            @Result(column = "profession", property = "profession", jdbcType = JdbcType.VARCHAR)
    })
    List<GaoyuanRecord1> selectAll();


    @Update({
            "update gaoyuan_record1",
            //" name = #{name,jdbcType=VARCHAR},",
//            "set sex=  #{sex,jdbcType=VARCHAR}",
            "set age = #{age,jdbcType=VARCHAR}",
//            "birthday = #{birthday,jdbcType=VARCHAR},",
//            "phone = #{phone,jdbcType=VARCHAR},",
//            "email = #{email,jdbcType=VARCHAR},",
//            "address = #{address,jdbcType=VARCHAR},",
//            "profession = #{profession,jdbcType=VARCHAR}",
            "where name = #{name,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(String name, String age);

    @Update({
            "update gaoyuan_record1",
            //" name = #{name,jdbcType=VARCHAR},",
//            "set sex=  #{sex,jdbcType=VARCHAR}",
//            "age = #{age,jdbcType=INTEGER},",
//            "birthday = #{birthday,jdbcType=VARCHAR},",
//            "phone = #{phone,jdbcType=VARCHAR},",
//            "email = #{email,jdbcType=VARCHAR},",
            "set address = #{address,jdbcType=VARCHAR}",
//            "profession = #{profession,jdbcType=VARCHAR}",
            "where name = #{name,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey1(String name, String address);

    @Update({
            "update gaoyuan_record1",
            //" name = #{name,jdbcType=VARCHAR},",
//            "set sex=  #{sex,jdbcType=VARCHAR}",
//            "age = #{age,jdbcType=INTEGER},",
//            "birthday = #{birthday,jdbcType=VARCHAR},",
//            "phone = #{phone,jdbcType=VARCHAR},",
//            "email = #{email,jdbcType=VARCHAR},",
//            "set address = #{address,jdbcType=VARCHAR},",
            "set profession = #{profession,jdbcType=VARCHAR}",
            "where name = #{name,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey2(String name, String profession);

    @Update({
            "update gaoyuan_record1",
            //" name = #{name,jdbcType=VARCHAR},",
//            "set sex=  #{sex,jdbcType=VARCHAR}",
//            "age = #{age,jdbcType=INTEGER},",
//            "birthday = #{birthday,jdbcType=VARCHAR},",
//            "phone = #{phone,jdbcType=VARCHAR},",
            "set email = #{email,jdbcType=VARCHAR}",
//            "set address = #{address,jdbcType=VARCHAR},",
//            "set profession = #{profession,jdbcType=VARCHAR}",
            "where name = #{name,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey3(String name, String email);


    @Update({
            "update gaoyuan_record1",
            //" name = #{name,jdbcType=VARCHAR},",
//            "set sex=  #{sex,jdbcType=VARCHAR}",
//            "age = #{age,jdbcType=INTEGER},",
//            "birthday = #{birthday,jdbcType=VARCHAR},",
            "set phone = #{phone,jdbcType=VARCHAR",
//            "email = #{email,jdbcType=VARCHAR},",
//            "set address = #{address,jdbcType=VARCHAR},",
//            "set profession = #{profession,jdbcType=VARCHAR}",
            "where name = #{name,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey4(String name, String phone);

    @Update({
            "update gaoyuan_record1",
            //" name = #{name,jdbcType=VARCHAR},",
//            "set sex=  #{sex,jdbcType=VARCHAR}",
//            "age = #{age,jdbcType=INTEGER},",
            "set  birthday = #{birthday,jdbcType=VARCHAR}",
//            "phone = #{phone,jdbcType=VARCHAR},",
//            "set email = #{email,jdbcType=VARCHAR},",
//            "set address = #{address,jdbcType=VARCHAR},",
//            "set profession = #{profession,jdbcType=VARCHAR}",
            "where name = #{name,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey5(String name, String birthday);

}
